package cn.pconline.autoclub.entity;

import java.util.Date;
import org.apache.commons.lang.StringUtils;
import org.gelivable.dao.Column;
import org.gelivable.dao.Entity;
import org.gelivable.dao.Id;
import org.gelivable.dao.Transient;

/**
 * @author 作者 guoqiang
 * @version 2014-1-21 活动日记
 */
@Entity(tableName = "ac_activity_diary")
public class ActivityDiary {
    //private static final String defaulImg = "http://www1.pcauto.com.cn/bbs/cargroup/2014/images/defaultphoto2.png";

    /**
     * 日记ID
     */
    @Id
    @Column(name = "diary_id")
    private long diaryId;
    /**
     * 活动ID
     */
    @Column(name = "activity_id")
    private long activityId;
    /**
     * 贴ID
     */
    @Column(name = "topic_id")
    private long topicId;
    /**
     * 原贴URL
     */
    @Column(name = "topic_url")
    private String topicUrl;
    /**
     * 原帖标题
     */
    @Column(name = "title")
    private String title;
    /**
     * 原帖内容
     */
    @Column(name = "content")
    private String content;
    /**
     * 原帖封面图url
     */
    @Column(name = "topic_cover")
    private String topicCover;
    /**
     * 排序
     */
    @Column(name = "seq")
    private int seq;
    /**
     * 创建时间
     */
    @Column(name = "create_at")
    private Date diaryCreate;
    /**
     * 修改时间
     */
    @Column(name = "update_At")
    private Date diaryUpdate;
    /**
     * 创建人
     */
    @Column(name = "create_by")
    private int createBy;
    /**
     * 创建人名称
     */
    @Column(name = "create_name")
    private String createName;
    /**
     * 车友会ID
     */
    @Column(name = "club_id")
    private long clubId;
    /**
     * 日记时间
     */
    @Column(name = "begin_at")
    private Date beginAt;
    /**
     * 省名称
     */
    @Column(name = "province_name")
    private String provinceName;
    /**
     * 省ID
     */
    @Column(name = "province_id")
    private long provinceId;
    /**
     * 市ID
     */
    @Column(name = "city_id")
    private long cityId;
    /**
     * 市名称
     */
    @Column(name = "city_name")
    private String cityName;
    /**
     * 图片一
     */
    @Column(name = "image1_url")
    private String image1Url;
    /**
     * 图片二
     */
    @Column(name = "image2_url")
    private String image2Url;
    /**
     * 图片三
     */
    @Column(name = "image3_url")
    private String image3Url;
    @Transient(cache = false)
    private String appImage1;
    @Transient(cache = false)
    private String appImage2;
    @Transient(cache = false)
    private String appImage3;
    @Transient(cache = false)
    private Club club;

    public String getAppImage1() {
        return convertImgage(image1Url);
    }

    public String getAppImage2() {
        return convertImgage(image2Url);
    }

    public String getAppImage3() {
        return convertImgage(image3Url);
    }

    public String convertImgage(String image) {
        if (StringUtils.isNotBlank(image) && image.indexOf("_1024x1024") > 0) {
            return image.replace("_1024x1024", "_240x160");
        }
        return image;
    }

    public long getDiaryId() {
        return diaryId;
    }

    public void setDiaryId(long diaryId) {
        this.diaryId = diaryId;
    }

    public long getActivityId() {
        return activityId;
    }

    public void setActivityId(long activityId) {
        this.activityId = activityId;
    }

    public long getTopicId() {
        return topicId;
    }

    public void setTopicId(long topicId) {
        this.topicId = topicId;
    }

    public String getTopicUrl() {
        return topicUrl;
    }

    public void setTopicUrl(String topicUrl) {
        this.topicUrl = topicUrl;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTopicCover() {
//		if(StringUtils.isBlank(topicCover)){
//			setTopicCover(defaulImg);
//		}
        return topicCover;
    }

    public void setTopicCover(String topicCover) {
        this.topicCover = topicCover;
    }

    public int getSeq() {
        return seq;
    }

    public void setSeq(int seq) {
        this.seq = seq;
    }

    public Date getDiaryCreate() {
        return diaryCreate;
    }

    public void setDiaryCreate(Date diaryCreate) {
        this.diaryCreate = diaryCreate;
    }

    public Date getDiaryUpdate() {
        return diaryUpdate;
    }

    public void setDiaryUpdate(Date diaryUpdate) {
        this.diaryUpdate = diaryUpdate;
    }

    public int getCreateBy() {
        return createBy;
    }

    public void setCreateBy(int createBy) {
        this.createBy = createBy;
    }

    public String getCreateName() {
        return createName;
    }

    public void setCreateName(String createName) {
        this.createName = createName;
    }

    public long getClubId() {
        return clubId;
    }

    public void setClubId(long clubId) {
        this.clubId = clubId;
    }

    public String getProvinceName() {
        return provinceName;
    }

    public void setProvinceName(String provinceName) {
        this.provinceName = provinceName;
    }

    public long getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(long provinceId) {
		this.provinceId = provinceId;
	}

	public long getCityId() {
		return cityId;
	}

	public void setCityId(long cityId) {
		this.cityId = cityId;
	}

	public String getCityName() {
        return cityName;
    }

    public void setCityName(String cityName) {
        this.cityName = cityName;
    }

    public Date getBeginAt() {
        return beginAt;
    }

    public void setBeginAt(Date beginAt) {
        this.beginAt = beginAt;
    }

    public String getImage1Url() {
//		if(StringUtils.isBlank(image1Url)){
//			setImage1Url(defaulImg);
//		}
        return image1Url;
    }

    public void setImage1Url(String image1Url) {
        this.image1Url = image1Url;
    }

    public String getImage2Url() {
//		if(StringUtils.isBlank(image2Url)){
//			setImage2Url(defaulImg);
//		}
        return image2Url;
    }

    public void setImage2Url(String image2Url) {
        this.image2Url = image2Url;
    }

    public String getImage3Url() {
//		if(StringUtils.isBlank(image3Url)){
//			setImage3Url(defaulImg);
//		}
        return image3Url;
    }

    public void setImage3Url(String image3Url) {
        this.image3Url = image3Url;
    }

    public Club getClub() {
        return club;
    }

    public void setClub(Club club) {
        this.club = club;
    }
}
